<?php
namespace App\Modules\Admin\Controllers;

use App\Http\Resources\Admin\DictResource;
use App\Modules\Admin\Services\DictService;
use Illuminate\Http\Request;


class DictController extends AdminController
{
    public function index(Request $request, DictService $service)
    {
        $dicts = DictResource::collection($service->page($request->all()));

        return $this->responseSuccess([
            'list' => $dicts,
            'total' => $dicts->total()
        ]);
    }

    public function add(Request $request, DictService $service)
    {
        return $this->responseSuccess($service->add($request->all()));
    }

    public function edit(Request $request, Int $id, DictService $service)
    {
        return $this->responseSuccess($service->edit($id, $request->all()));

    }

    public function detail(Int $id, DictService $service)
    {
        return $this->responseSuccess($service->detail($id));

    }

    public function del(Int|String $id, DictService $service)
    {
        return $this->responseSuccess($service->del($id));
    }

    public function options(String $typeCode, DictService $service)
    {
        return $this->responseSuccess($service->options($typeCode));
    }
}